package com.dhy.qigsaw.splash.data;

import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.dhy.qigsaw.splash.ApiUtil;
import com.dhy.versionchecker.IVersion;

public class AppVersionExt extends AppVersion implements IVersion {
    @Override
    public void setPatchUrl(@Nullable String url) {
        patchUrl = url;
    }

    @Override
    public void setPatchSize(long size) {
        patchSize = size;
    }

    @Override
    public boolean isForceUpdate() {
        return forceUpdate == 1;
    }

    @Override
    public long getSize() {
        return size;
    }

    @NonNull
    @Override
    public String getUrl() {
        return url;
    }

    public String patchUrl;

    @Nullable
    @Override
    public String getPatchUrl() {
        return patchUrl;
    }

    public long patchSize;

    @Override
    public long getPatchSize() {
        return patchSize;
    }

    @NonNull
    public String getVersionName() {
        if (versionName != null) {
            return versionName;
        } else return "";
    }

    @Override
    public int getVersionCode() {
        return versionCode;
    }

    @Override
    public int getCurrentVersionCode() {
        return ApiUtil.INSTANCE.getAppConfig().getVERSION_CODE();
    }

    @Override
    public boolean isNew() {
        return getCurrentVersionCode() < versionCode;
    }

    @Override
    public String getLog() {
        return TextUtils.isEmpty(message) ? "" : message;
    }
}
